## Temelia, C generic data structures library

# Samples for temelia, generic data structures library.
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld

CFLAGS = -g -Wall -ltemelia -lm -O2
CROSS_FLAGS= -Wall -O2 -DDLL -L. -I/usr/include/
SAMPLES_BIN=temelia_samples
SAMPLES_EXE=temelia_samples.exe

# Test sources folder
SRCDIR = src

# Object files
OBJS = $(shell ls $(SRCDIR)/*.c|tr '\n' ' '|sed -n -e s/\\.c/.o/gp)

# what to build: an executable capable of loading data structures tests
all: $(SAMPLES_BIN)

$(SAMPLES_BIN): $(OBJS)
ifeq ($(CC), gcc)
	$(CC) $(CFLAGS) $(OBJS) -o $(SAMPLES_BIN)
else
	$(CC) -o $(SAMPLES_EXE) $(OBJS) $(CROSS_FLAGS) -lm -ltemelia
endif 

# given an object ($@) that has a corresponding C source ($<), build it
.c.o:
ifeq ($(CC), gcc)
	$(CC) $(CFLAGS) -c "$<" -o "$@"
else
	$(CC) $(CROSS_FLAGS) -c "$<" -o "$@"
endif 

.PHONY: clean
clean:
	-rm -rf $(SAMPLES_BIN) $(SAMPLES_EXE) $(OBJS)
